import sys
import time

bank = {
    'users':['lxf','xxy','ly'],
    'pwd': ['0618', '0818','0406'],
    'money':[5000,5000,5000],
    'history':[[5000],[5000],[5000]]
}

while True:
    user_now_name = str(input("欢迎使用本系统！请输入您的用户名：\n"))
    if user_now_name in bank['users']:
        user_index = bank['users'].index(user_now_name)
        # print('尊敬的', user_now_name, '您好！')
        while True:
            user_now_pwd = str(input("请输入您的密码：\n"))
            if user_now_pwd == bank['pwd'][user_index]:
                print('登录成功！')
                isLogin = True
                bank['history'][user_index].append(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '         登陆系统')
                break
            else:
                print('密码错误，请重试！\n')
        break
    else:
        print('抱歉，不存在该用户！\n')


while isLogin:
     print('\n请选择您要办理的业务：1.取款，2.存款，3.查询，4.退卡')
     service_num = int(input())
     if service_num == 1:
        money_out = int(input('请输入取款金额：'))
        if money_out > 0 and money_out < int(bank['money'][user_index]):
            bank['money'][user_index]  = int(bank['money'][user_index]) - money_out
            print('当前剩余存款：', bank['money'][user_index])
            bank['history'][user_index].append(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '         取款' + str(money_out))
        else:
            print('当前余额不足！！')
     elif service_num == 2:
        money_in = int(input('请输入存款金额：'))
        if money_in < 0:
            print('存款金额必须大于0')
        else:
            bank['money'][user_index]  = int(bank['money'][user_index]) + money_in
            print('当前剩余存款：', bank['money'][user_index])
            bank['history'][user_index].append(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '         存款' + str(money_in))
     elif service_num == 3:
         for record in bank['history'][user_index]:
            print(record)
     elif service_num == 4:
         bank['history'][user_index].append(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '         退出系统')
         break

